package com.Arsanesia.TempleRush.Controllers.Listeners;

import com.Arsanesia.TempleRush.TempleRush;
import com.Arsanesia.TempleRush.Controllers.World;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Image;

public class QuitAttemptListener extends ChangeScreenOnClickListener{
	private final float SIDE_MARGIN = 20;
	private final float BUTTON_WIDTH = 58;
	private final float BUTTON_HEIGHT = 69;
	private Image quitImage;
	private Rectangle okbound, cancelbound;
	private World world;
	public QuitAttemptListener(TempleRush game) {
		super(game);
	}
	public QuitAttemptListener(TempleRush game, Image _quitimage, World theworld){
		this(game);
		this.quitImage = _quitimage;
		okbound = new Rectangle(quitImage.getWidth()-SIDE_MARGIN-BUTTON_WIDTH,0,BUTTON_WIDTH, BUTTON_HEIGHT);
		cancelbound = new Rectangle(SIDE_MARGIN,0,BUTTON_WIDTH, BUTTON_HEIGHT);
		world = theworld;
	}
	public void clicked(InputEvent event, float x, float y){
		super.clicked(event, x, y);

		//only active when image showed up
		if(quitImage.getColor().a == 1){
			if(okbound.contains(x, y))
				world.gameOver();//game.setScreen(game.getGameOverScreen()); //to menu screen
			else if(cancelbound.contains(x,y))
				quitImage.addAction(Actions.alpha(0)); //make button invisible
		}
	}

}
